<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body>
    <div>aaa</div>
    <script>
      class Pom {
        constructor() {
          this.core = [];
        }
        addEventHandler(f) {
          this.core.push(f);
        }
      }
      let pom = new Pom();
      pom.addEventHandler((x) => {
        console.log("first", x);
      });
      pom.addEventHandler((x) => {
        console.log("second", x);
      });

      function* queue() {
        while (true) {
          let p = yield 12;
          console.log("======queue中进入", p, "将要被消费=============");
          pom.core.forEach((f) => {
            f(p);
          });
        }
      }

      let s = queue();
      s.next();
    </script>
  </body>
</html>
